﻿@model MealBooking.Core.Models.Orders.Order
@{
    var order = Model;
    Layout = "~/Areas/Manager/Views/Shared/_Layout.cshtml";
}
<!--Navbar-->
<div data-role="navbar" data-iconpos="left">
    <div class="float-left">
        <div data-role="controlgroup" data-type="horizontal" data-inset="true" data-mini="true"
            data-theme="c">
            <!--nav bar options-->
            <a href="@Url.Action("Detail", "AccountManager", new { id = order.Account.Id })" data-role="button" data-icon="check" data-theme="a">
                Ordered By @order.Account.Name</a>
            @if (order.IsBooked)
            {
                <a href="@Url.Action("Index", "Account")" data-role="button" data-icon="check" data-theme="a">
                    Booked By @order.Manager.Name
                </a>                    
            }
            else
            {
                <button data-role="button" data-icon="delete" data-theme="a">
                    Not Booked</button>
            }
        </div>
    </div>
    <div class="float-right">
        <div data-role="controlgroup" data-type="horizontal" data-inset="true" data-mini="true"
            data-theme="c">
            <a href="@Url.Action("TodayOrders")">Customers' Orders</a> <a href="@Url.Action("HistoryOrder")">
                History Orders</a>
        </div>
    </div>
</div>
<!--Navbar End-->
<ul data-role="listview" data-inset="true" data-mini="true">
    <li data-role="list-divider">Total Price : @order.TotalPrice</li>
    <li>
        <p>
            Created Time : @order.CreatedTime</p>
        <p>
            Last Update Time : @order.LastUpdateTime</p>
    </li>
    <li data-role="list-divider">Detail<span class="ui-li-count">@order.MealsWithSum.Sum(m => m.MealSum)</span>
    </li>
    @{
        var mealsWithSum = order.MealsWithSum;
        foreach (var mealWithSum in mealsWithSum)
        {
            var meal = mealWithSum.Meal;
            double totalPrice = mealWithSum.Meal.Price * mealWithSum.MealSum;
        <li>
            <p>
                <strong>[@mealWithSum.MealSum Copy][@meal.Category.Name][@meal.ToString()] </strong>
            </p>
            <p>
                Total Price : @totalPrice [@meal.Price
                X @mealWithSum.MealSum]</p>
        </li>
        }        
    }
</ul>
